<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var nums = [0, 1, 2, 2, 4, 4, 4, 1, 6]
    function fn(arr) {
      let res = -1;
      let times = -1;
      const map = {};
      for (let i of arr) {
        if (i % 2 == 0) {
          map[i] = (map[i] || 0) + 1;
          if (map[i] > times) {
            res = i;
            times = map[i];
          }
        }
      }
      return res
    }
    console.log(fn(nums));

  </script>
</body>

</html>